package com.avantis.admin.config.shiro;

import org.apache.shiro.cache.Cache;
import org.apache.shiro.cache.CacheException;
import org.apache.shiro.cache.CacheManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

@Component
public class YaphetsCacheManager implements CacheManager {

    /**
     * important 此处注入的redisTemplate的KV序列化器都是二进制格式的！！！
     */
    @Autowired
    private RedisTemplate redisTemplate;


    @Override
    public <K, V> Cache<K, V> getCache(String name) throws CacheException {
        return new ShiroRedisCache<K,V>(120*1000,redisTemplate);
    }
}
